home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / Tickle-4.0 (tcl) / library / help / tcl / libraries / packagelib < prev    next >
Encoding:
Text File  |  1993-10-26  |  3.3 KB  |  63 lines  |  [TEXT/$Tcl]

  1.  
  2.  
  3.      TCL LOADABLE LIBRARIES AND PACKAGES
  4.           Extended Tcl supports standard Tcl  tclIndex  libraries  and
  5.           package libraries. A package library file can contain multi-
  6.           ple independent Tcl packages.  A package is a named  collec-
  7.           tion of related Tcl procedures and initialization code.
  8.  
  9.           The package library file is just a regular Unix  text  file,
  10.           editable with your favorite text editor, containing packages
  11.           of Tcl source code. The package library file name must  have
  12.           the  suffix  .tlib.   An  index  file with the suffix .tndx,
  13.           corresponding to the package library.   The  .tndx  will  be
  14.           automatically  created  by Tcl whenever it is out of date or
  15.           missing (provided there is write access to the directory.
  16.  
  17.           The variable auto_path contains a list of  directories  that
  18.           are  searched for libraries.  The first time an unknown com-
  19.           mand trap is take, the indexes for the libraries are  loaded
  20.           into  memory.  If  the  auto_path variable is changed during
  21.           execution of a program, it will  be  re-searched.  Only  the
  22.           first  package of a given name found during the execution of
  23.           a program is loaded.  This can be overridden with loadlibin-
  24.           dex command.
  25.  
  26.           The start of a package is delimited by:
  27.  
  28.                #@package: package_name proc1 ?..procN?
  29.  
  30.           These lines must start in column  one.   Everything  between
  31.           the  #@package: keyword and the next #@package: keyword or a
  32.           #@packend keyword, or the end of the file, becomes  part  of
  33.           the  named package.  The specified procedures, proc1..procN,
  34.           are the entry points of the package.  When a  command  named
  35.           in  a  package  specification is executed and detected as an
  36.           unknown command, all code in the specified package  will  be
  37.           sourced.   This  package should define all of the procedures
  38.           named on the package line,  define  any  support  procedures
  39.           required by the package and do any package-specific initial-
  40.           ization.  Packages declarations maybe  continued  on  subse-
  41.           quent lines using standard Tcl backslash line continuations.
  42.           The #@packend keyword  is  useful  to  make  sure  only  the
  43.           minimum required section of code is sourced.  Thus for exam-
  44.           ple a large comment block at the beginning of the next  file
  45.           won't be loaded.
  46.  
  47.           Care should be taken in defining package_name, as the  first
  48.           package  found  in  the path by with a given name is loaded.
  49.           This can be useful in developing  new  version  of  packages
  50.           installed on the system.
  51.  
  52.           For example, in a package source file, the presence  of  the
  53.           following line:
  54.  
  55.                #@package: directory_stack pushd popd dirs
  56.  
  57.           says that the text lines following that line in the  package
  58.           file up to the next package line or the end of the file is a
  59.           package named directory_stack and that an attempt to execute
  60.           either  pushd,  popd or dirs when the routine is not already
  61.           defined will cause the directory_stack portion of the  pack-
  62.           age file to be loaded.
  63.